#ifndef _KTV_GRAPHICS_H_
#define _KTV_GRAPHICS_H_

#include "ui_rect.h"
#include "ui_color.h"
#include "ui_point.h"
#include "ui_window.h"
#include "SDL/SDL.h"


namespace UI
{

class UI_Painter
{
public:
	enum EPaintMode {
		PAINT_IGNORE = 0,  //!< Don't actually draw anything
		PAINT_REPLACE,  //!< Replace the pixel with the new pixel
		PAINT_NORMAL,  //!< Do normal color mixing (uses the alpha channel)
		PAINT_OR,  //!< OR the new color in
		PAINT_AND,  //!< AND the new color in
		PAINT_XOR,  //!< XOR the new color in
		PAINT_ADDITIVE  //!< Use Additive color mixing
	};
	UI_Painter(SDL_Surface* pSurface, EPaintMode ePaintMode = PAINT_NORMAL);
	UI_Painter(UI_Window* pWindow, EPaintMode ePaintMode = PAINT_NORMAL);
	virtual ~UI_Painter(void) { }
	void DrawHLine(int xStart, int xEnd, int y, const UI_Color& LineColor = DEFAULT_LINE_COLOR);
	void DrawVLine(int yStart, int yEnd, int x, const UI_Color& LineColor = DEFAULT_LINE_COLOR);
	void DrawRect(const UI_Rect& Rect, bool bFilled, const UI_Color& BorderColor = DEFAULT_LINE_COLOR,
		const UI_Color& FillColor = DEFAULT_FOREGROUND_COLOR);
	void DrawLine(const UI_Point& StartPoint, const UI_Point& EndPoint, const UI_Color& LineColor = DEFAULT_LINE_COLOR);
	void DrawPoint(const UI_Point& Point, const UI_Color& PointColor = DEFAULT_LINE_COLOR);
	UI_Color ReadPoint(const UI_Point& Point);
	void ReplaceColor(const UI_Color& NewColor, const UI_Color& OldColor);
	void TransparentColor(const UI_Color& TransparentColor);
protected:
	void LockSurface(void);
	void UnlockSurface(void);
	UI_Color MixColor(const UI_Color& ColorBase, const UI_Color& ColorAdd);
	SDL_Surface* m_pSurface;
	UI_Window* m_pWindow;
	EPaintMode m_PaintMode;
};


}

#endif // _KTV_GRAPHICS_H_

